#include "CStateManager.h"


CStateManager::CStateManager(IGamePlay *game)
{
	m_pGraphic		= game->m_Graphic;
	m_pInput		= game->m_Input;

	m_CurrentState	= NULL;
	m_NextState		= NULL;
}

CStateManager::~CStateManager()
{
	m_pGraphic		= NULL;
	m_pInput		= NULL;
	m_CurrentState	= NULL;
	m_NextState		= NULL;
}


void CStateManager::Init()
{
	m_CurrentState = m_NextState = new MapTest(this);
	m_CurrentState->Init();
}

void CStateManager::Update()
{
	if( m_CurrentState != m_NextState )
	{
		m_CurrentState->Destroy();
		m_CurrentState = m_NextState;
		m_CurrentState->Init();
	}

	m_CurrentState->Update();
}

void CStateManager::Render()
{
	m_CurrentState->Render();
}

void CStateManager::Destroy()
{
	m_CurrentState->Destroy();
}

void CStateManager::SetState(IGameState *state)
{
	m_NextState = state;
}


